<template>
  <view class="container">
    <!-- 宽屏设置界面 -->
    <scroll-view scroll-x="true" class="scroll-container">
      <view class="settings-container">
        <view class="settings-header">
          <text class="header-title">系统参数设置</text>
        </view>
        
        <view class="settings-content">
          <view class="setting-group">
            <view class="setting-label">URL地址</view>
            <input 
              class="setting-input" 
              type="text" 
              v-model="settings.url"
              placeholder="请输入服务器URL地址"
            />
          </view>
          
          <view class="setting-group">
            <view class="setting-label">科室信息</view>
            <input 
              class="setting-input" 
              type="text" 
              v-model="settings.department"
              placeholder="请输入科室名称"
            />
          </view>
          
          <view class="setting-group">
            <view class="setting-label">床号</view>
            <input 
              class="setting-input" 
              type="text" 
              v-model="settings.bedNumber"
              placeholder="请输入病床编号"
            />
          </view>
        </view>
        
        <view class="settings-footer">
          <button class="btn btn-save" @click="saveSettings">保存设置</button>
          <button class="btn btn-cancel" @click="cancelSettings">取消</button>
        </view>
      </view>
    </scroll-view>
    
    <!-- 提示信息 -->
    <view v-if="showToast" class="toast">{{ toastMessage }}</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      settings: {
       
      },
      originalSettings: {},
      showToast: false,
      toastMessage: ''
    }
  },
  onShow() {
  	this.getLocalSetting();
  },
  methods: {
    saveSettings() {
      uni.setStorageSync('systemSettings', this.settings);
      this.showToastMessage('设置已保存成功！');
	  uni.navigateTo({
	  	url: '../index/index'
	  });
    },
	getLocalSetting()
	{
		var localSetting = uni.getStorageSync('systemSettings');
		if (localSetting)
		{
			this.settings = localSetting;
		}
	},
	
    cancelSettings() {
		this.getLocalSetting()
    },
	
    showToastMessage(message) {
      this.toastMessage = message;
      this.showToast = true;
      setTimeout(() => {
        this.showToast = false;
      }, 2000);
    }
  }
}
</script>

<style scoped>
/* 全局容器，允许水平滚动 */
.container {
  width: 100%;
  height: 360px;
  overflow: hidden;
  background-color: #1f2937;
}

.scroll-container {
  width: 100%;
  height: 360px;
}

/* 设置界面容器，固定1920*360尺寸 */
.settings-container {
  width: 1920px;
  height: 360px;
  background: #000E2B;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.settings-header {
  height: 60px;
  background-color: #26324C;
  display: flex;
  align-items: center;
  padding: 0 40px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-title {
  color: white;
  font-size: 24px;
  font-weight: 500;
}

.settings-content {
  display: flex;
  flex: 1;
  padding: 30px;
}

.setting-group {
  flex: 1;
  margin: 0 15px;
  background-color: #384768;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.setting-label {
  font-size: 18px;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid #fff;
}

.setting-input {
  flex-grow: 1;
  padding: 12px 15px;
  font-size: 18px;
  border: 2px solid #374151;
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.setting-input:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.settings-footer {
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  background-color: #26324C;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px;
}

.btn {
  padding: 10px 30px;
  font-size: 18px;
  font-weight: 600;
  border: none;
  margin: 0 10px;
  border-radius: 0;
  width: 200px;
}

.btn-save {
  background-color: #95BE84;
  color: white;
}

.btn-save:active {
  background-color: #0da271;
}

.btn-cancel {
  background-color: #E84442;
  color: white;
}

.btn-cancel:active {
  background-color: #E50112;
}

.toast {
  position: fixed;
  top: 45px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px 20px;
  z-index: 9999;
  font-size: 16px;
}

</style>